$package('YiYa.merchant');
YiYa.merchant = function(){
	var _box = null;
	var _this = {
		config:{
			dataGrid:{
				title:'原材料进货明细列表',
				url:'dataList.do?type=1&product.type=2',
				columns:[[
				          {field:'id',checkbox:true},
				          {field:'number',title:'货单号',width:120,sortable:true},
				          {field:'product_name',title:'原材料名称',width:120,
				        	  formatter:function(value,row,index){
				        		  return new Object(row["product"]).name;
						  }},
						  {field:'merchant_name',title:'供应商',width:120,
				        	  formatter:function(value,row,index){
				        		  return new Object(row["merchant"]).name;
						  }},
						  {field:'repository_name',title:'所在仓库',width:80,
				        	  formatter:function(value,row,index){
				        		  return new Object(row["repository"]).name;
						  }},
				          {field:'quantity',title:'数量',width:120,sortable:true},
				          {field:'bill_date',title:'账单日期',width:120,sortable:true,
				        	  formatter:function(value,row,index){
				        		  return new Date(row["billDate"]).format("yyyy-MM-dd");
						  }}
				          ]],
				          toolbar:[
				                   {id:'btnadd',text:'添加',btnType:'add'},
				                   {id:'btnedit',text:'编辑',btnType:'edit'},
				                   {id:'btndelete',text:'删除',btnType:'remove'},
				                   ]
			}
		},
		init:function(){
			$('#dd').datebox({
			    formatter: function(date){ return date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate();},
			    parser: function(date){ return new Date(Date.parse(date.replace(/-/g,"/")));}
			});
			_box = new YDataGrid(_this.config);
			_box.init();
		}
	}
	return _this;
}();

$(function(){
	YiYa.merchant.init();
});


